package com.fr.report.script.function;

import com.fr.report.script.Function;
import com.fr.report.script.Function.Type;
import com.fr.report.script.NormalFunction;
import com.fr.report.script.Primitive;
import com.fr.report.script.core.FunctionHelper;

public class ATANH extends NormalFunction
{
  public Object run(Object[] paramArrayOfObject)
  {
    if (paramArrayOfObject.length < 1)
      return Primitive.ERROR_NAME;
    Object localObject = paramArrayOfObject[0];
    if (localObject instanceof Number)
    {
      double d = ((Number)localObject).doubleValue();
      return FunctionHelper.parsePrimitiveDouble(Math.log((1.0D + d) / (1.0D - d)) / 2.0D);
    }
    return Primitive.ERROR_NAME;
  }

  public Function.Type getType()
  {
    return Function.MATH;
  }

  public String getCN()
  {
    return "ATANH(number): 返回数字的反双曲正切值，该函数的参数值即为反双曲正切值的双曲正切值。\nNumber:指介于-1~1之间的任意实数。\n备注:\n    指定的number必须介于-1~1之间（不包括-1，1）。\n    ATANH(TANH(number))=number，例如，ATANH(TANH(8))=8。\n示例:\nATANH(-0.5)等于-0.549306144。\nATANH(0)等于0。\nATANH(0.7)等于0.867300528。";
  }

  public String getEN()
  {
    return "ATANH(number): Returns the inverse hyperbolic tangent of a number. \n\nRemarks:\n    Number must be between -1 and 1 (excluding -1 and 1).\n    ATANH(TANH(number))=number, for example ATANH(TANH(8))=8.\n\nExample:\n   ATANH(-0.5) = -0.549306144\n   ATANH(0) = 0\n   ATANH(0.7) = 0.867300528";
  }
}